/*
 * @Author: january.cjy 
 * @Date: 2021-09-27 20:19:17 
 * @Last Modified by: january.cjy
 * @Last Modified time: 2021-09-27 20:54:58
 */
/*
 * @Author: january.cjy 
 * @Date: 2021-09-27 19:49:52 
 * @Last Modified by: january.cjy
 * @Last Modified time: 2021-09-27 19:54:06
 */
#pragma once

#include "clang/AST/AST.h"
#include "clang/AST/RecursiveASTVisitor.h"
#include "clang/Frontend/CompilerInstance.h"

#include <CmgASTConsumer.h>
#include <CmgPPCallbacks.h>

namespace cmg{
using namespace clang;
using namespace llvm;
class CmgASTFrontendAction : public ASTFrontendAction {
public:
  virtual bool BeginSourceFileAction(CompilerInstance &ci) {
    ci.getPreprocessor().addPPCallbacks(
      std::unique_ptr<clang::PPCallbacks>(new CmgPPCallbacks(ci.getSourceManager()))
    );
    return true;
  }

  virtual std::unique_ptr<clang::ASTConsumer>
  CreateASTConsumer(CompilerInstance &Compiler, StringRef InFile) {
    return std::unique_ptr<clang::ASTConsumer>(new CmgASTConsumer(Compiler.getASTContext(),Compiler.getSourceManager(),Compiler.getPreprocessor()));
  }

//   ~CmgASTFrontendAction() {}

private:
};

}